home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / video.h < prev    next >
C/C++ Source or Header  |  1988-12-15  |  8KB  |  192 lines

  1. /* VIDEO.H -- after Microsoft Systems Journal, Nov. 1988, p. 10 */
  2.  
  3. /*---------------------------------------------------------------*/
  4. /* Direct Screen I/O, compatible with Monochrome or CGA adapters */
  5. /* including Microsoft's own "snow elimination" algorithm.       */
  6. /*---------------------------------------------------------------*/
  7.  
  8. /* FAFNIR library provides direct screen i/o support for Small and
  9.    Large memory models.  Medium (/AM), Compact (/AC) and Huge (/AH) 
  10.    memory models are not currently supported; these need their own
  11.    assembler modules and some vetting in the C library code to work
  12.    properly.
  13.  
  14.    There are 14 direct-video functions:
  15.  
  16.         in CVIDEO.C:
  17.  
  18.         extern void MSJ_GetVideoParms();
  19.         extern void MSJ_ClrScr();
  20.         extern void MSJ_ClrRegion();
  21.         extern void MSJ_TextBox();
  22.         extern void MSJ_SaveRegion();
  23.         extern void MSJ_RestRegion();
  24.  
  25.         in xVIDEO.ASM (where x is S,M,CM,L):
  26.  
  27.         extern void far * cdecl MSJ_FarPtr( void near * );
  28.         extern int        cdecl MSJ_GetCharAttr();
  29.         extern void       cdecl MSJ_DispCharAttr();
  30.         extern void       cdecl MSJ_DispString();
  31.         extern void       cdecl MSJ_DispMsgLen();
  32.         extern void       cdecl MSJ_SetFldAttr();
  33.         extern void       cdecl MSJ_MovScrBuf();
  34.         extern void       cdecl MSJ_MovBufScr();
  35.  
  36.  
  37.    12/16/88, d.c.oshel, ames, ia
  38.    */
  39.  
  40. /* Considerations:  Prosise's original CVIDEO.C included calls to int86()
  41.                     indiscriminately in places other than GetVideoParms().
  42.                     This destroys the generality of the algorithm, by
  43.                     making it impossible to write to a general buffer
  44.                     other than the physical screen buffer, by forcing
  45.                     some CVIDEO routines to call ROM BIOS.
  46.  
  47.                     Note that an alternate screen buffer must assume
  48.                     a starting offset of 0, and a segment address aligned
  49.                     to make the first condition true.  I haven't included
  50.                     any real general support for hidden text screens, yet. 
  51.  
  52.                     What I've done is to add a couple of service routines
  53.                     to ASMVIDEO.ASM, and remove all int86()'s from this
  54.                     and my own libraries, with the exception of routines
  55.                     which read or update the physical cursor size or location, 
  56.                     or which initialize the i/o module.
  57.  
  58.                     The only remaining hardware-dependent code is in the
  59.                     assembler functions which use Microsoft's snow
  60.                     elimination algorithm.  These poll the CRTC video
  61.                     port (reads only) on the CGA card.
  62.  
  63.                     In general, these routines "bleed" onto the primary
  64.                     screen in "multi-tasking" emulations, such as DoubleDos
  65.                     or CodeView.  However, it is more important to keep
  66.                     low-level screen i/o as object-oriented as possible,
  67.                     than it is to adjust in all cases to programs written
  68.                     with a specific hardware orientation.  My goal here is
  69.                     PORTABILITY, not COMPATIBILITY.  This is, of course,
  70.                     a copout.  The problem has no good solution, so I
  71.                     have opted to pursue my own goals (in future development)
  72.                     whilst forcing the compromise.  Tough nuggies.
  73.  
  74.                     12/10/88, d.c.oshel, ames, iowa
  75.                     */
  76.  
  77. /*-------------------------------------------------------------------*/
  78. /*     CAUTION:  These routines do little or no error trapping!      */
  79. /*-------------------------------------------------------------------*/
  80.  
  81. /* Data */
  82.  
  83. struct MSJ_VideoInfo {
  84.     unsigned char mode;
  85.     unsigned char rows;
  86.     unsigned char columns;
  87.     unsigned char ColorFlag;
  88.     unsigned char SnowFlag;
  89.     unsigned int  BufferStart;
  90.     unsigned int  SegAddr;
  91. };
  92.  
  93. extern struct MSJ_VideoInfo video;  /* defined in CVIDEO.C */
  94.  
  95.  
  96. /* C function prototypes */
  97.  
  98. extern void MSJ_GetVideoParms( struct MSJ_VideoInfo * sptr );
  99.  
  100. extern void MSJ_ClrScr(     char VideoAttr, 
  101.                             struct MSJ_VideoInfo * sptr );
  102.  
  103. extern void MSJ_ClrRegion(  char row1, char col1, 
  104.                             char row2, char col2, 
  105.                             char VideoAttr );
  106.  
  107. extern void MSJ_TextBox(    char row1, char col1, 
  108.                             char row2, char col2, 
  109.                             char VideoAttr, 
  110.                             struct MSJ_VideoInfo * sptr );
  111.  
  112. extern void MSJ_SaveRegion( char row1, char col1, 
  113.                             char row2, char col2, 
  114.                             int * ScreenBuffer, 
  115.                             struct MSJ_VideoInfo * sptr );
  116.  
  117. extern void MSJ_RestRegion( char row1, char col1, 
  118.                             char row2, char col2, 
  119.                             int * ScreenBuffer, 
  120.                             struct MSJ_VideoInfo * sptr );
  121.  
  122.  
  123.  
  124. /* macro assembler functions */
  125.  
  126.  
  127. /* MSJ, Nov. 1988
  128.    */
  129. extern int cdecl MSJ_GetCharAttr( char row, char col, 
  130.                                   struct MSJ_VideoInfo * sptr );
  131.  
  132. /* MSJ, Nov. 1988
  133.    */
  134. extern void cdecl MSJ_DispCharAttr( char ch, 
  135.                                     char row, char col, 
  136.                                     char VideoAttr, 
  137.                                     struct MSJ_VideoInfo * sptr );
  138.  
  139.  
  140. /* MSJ, Nov. 1988
  141.    */
  142. extern void cdecl MSJ_DispString( char * msg, 
  143.                                   char row, char col, 
  144.                                   char VideoAttr, 
  145.                                   struct MSJ_VideoInfo * sptr ); 
  146.  
  147.  
  148. /* MSJ_DispMsgLen is like MSJ_DispString, but takes a length argument,
  149.    and does not disturb screen attributes in the receiving field
  150.    12/10/88, d.c.oshel
  151.    */
  152. extern void cdecl MSJ_DispMsgLen( char * msg, 
  153.                                   char row, char col, 
  154.                                   int len,
  155.                                   struct MSJ_VideoInfo * sptr ); 
  156.  
  157.  
  158. /* MSJ_SetFldAttr takes a length argument and clears a field of the
  159.    screen to the given char having the given attribute
  160.    12/10/88, d.c.oshel
  161.    */
  162. extern void cdecl MSJ_SetFldAttr( char ch, 
  163.                                   char row, 
  164.                                   char col, 
  165.                                   char VideoAttr,
  166.                                   int len,
  167.                                   struct MSJ_VideoInfo * sptr );
  168.  
  169.  
  170. /* move count WORDS from screen to far buffer, 12/10/88, d.c.oshel 
  171.    count is number of char/attr pairs to save or restore; be sure to 
  172.    ALLOCATE count * sizeof(int) ... !
  173.    */
  174. extern void cdecl MSJ_MovScrBuf(  char far * buffer,
  175.                                   char row,
  176.                                   char col,
  177.                                   int count,
  178.                                   struct MSJ_VideoInfo * sptr );
  179.  
  180.  
  181. /* move count WORDS from far buffer to screen, 12/10/88, d.c.oshel 
  182.    count is number of char/attr pairs to save or restore; be sure to 
  183.    ALLOCATE count * sizeof(int) ... !
  184.    */
  185. extern void cdecl MSJ_MovBufScr(  char far * buffer,
  186.                                   char row,
  187.                                   char col,
  188.                                   int count,
  189.                                   struct MSJ_VideoInfo * sptr );
  190.  
  191. /* eof */
  192.